﻿using System;
using System.Collections.Generic;
using System.Runtime.Serialization;

namespace SmartClientPlatform.OMS.CommonLibrary
{
    [Serializable]
    public class Class1
    {
        [OnSerialized]
        private void M1(StreamingContext streamingContext)
        {
            Console.WriteLine("d1");
        }

        [OnDeserialized]
        private void M2(StreamingContext streamingContext)
        {
            Console.WriteLine("d2");
        }

        private string a001 = "qwe";

        public string A001
        {
            get { return a001; }
            set { a001 = value; }
        }

        public Bbb Bbb { get; set; }
    }

    [Serializable]
    public class Bbb
    {
        private readonly Dictionary<string, Class1> dictionary;
        public Bbb()
        {
            dictionary = new Dictionary<string, Class1>
                             {
                                 {"a1", new Class1 {A001 = "t1"}},
                                 {"a2", new Class1 {A001 = "t2"}}
                             };
        }

        public string B001
        {
            get { return dictionary["a1"].A001; }
            set { dictionary["a1"].A001 = value; }
        }
    }
}
